<template>
  <!-- 放置一个图标 -->
  <!-- 全屏插件 -->
  <div>
    <svg-icon :icon-class="isFullscreen?'exit-fullscreen':'fullscreen'" class="fullscreen" @click="toggleScreen" />
  </div>
</template>

<script>
import screenfull from 'screenfull'
export default {
  name: 'ScreenFull',
  data() {
    return {
      isFullscreen: false// 是否全屏,用来控制图标
    }
  },
  mounted() {
  // 监听全屏的状态是否切换,按esc图标不转换
    screenfull.on('change', () => {
      this.isFullscreen = screenfull.isFullscreen
    })
  },
  methods: {
    toggleScreen() {
      screenfull.toggle()
      this.isFullscreen = !this.isFullscreen
    }
  }

}
</script>

<style lang="scss" scoped>
.fullscreen {
  width: 20px;
  height: 20px;
  color: #fff;
  cursor: pointer;
}
</style>
